
<%@ include file="/common/taglibs.jsp"%>
<!--分页查询共用的页面-->
<%@ include file="/common/common.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>

<script type="text/javascript" src="<%=jsPath%>/jquery/jquery.timers.js"></script><!--定时器-->
<script type="text/javascript" src="<%=jsPath%>/terminalCommand.js?v=1"></script><!--终端命令结果查询-->
	
<script>
	/*
	修改代码：
	1.新定义变量TerminalCommmand，为命令支持变量
	2.重定义id：
	原：null		现：capCommandMsg
	原：null		现：vasCommandMsg
	原：		现：
	*/

	var tc2VideoalarmShield = new TerminalCommand2();
    var timerName = "videoAlarmshieldTimer";
    ///////////////////////////////////////////////////////////////
    tc2VideoalarmShield.messageDiv = $("#vasCommandMsg");
	tc2VideoalarmShield.timerName = timerName;
	tc2VideoalarmShield.commandButton = $("#vasBtnQuery");

    //当查询终端参数命令执行成功时
    function onQueryCommandSuccess(result){
        if (result.success) {
            $(":checkbox").attr("checked",false);
            var v = parseInt(result.data[0].value);
            var p = v.toString(2).split("").reverse();
            for(var m = 0; m < p.length; m++)
			{
			    if(p[m] == "1")
				{
				    $("#alarmType"+m).attr("checked",true);
				}
			}
        }
    }
        $().ready(function() {
	 $("#vasEntityForm").validate(); //初始化验证信息
    $("#vasBtnQuery").click(function()
    {
        operation = "query";
        var url = "<%=ApplicationPath%>/videoTerminalParam/sendParamQueryCommand.action";
        var param = {paramId : 0x007A,vehicleId:${vehicleId}};
        $.getJSON(url, param, function(result)
		{
            if (result.success) {
                var commandId = result.data; //下发成功后，获取到命令Id
                tc2VideoalarmShield.commandButton = $("#vasBtnQuery");
                var url = "<%=ApplicationPath%>/terminalParam/queryTerminalParam.action";
                tc2VideoalarmShield.times=190;
                tc2VideoalarmShield.startQueryResult(commandId,url,onQueryCommandSuccess);//命令下发成功,根据命令id,开始尝试获取检索结果

				//TerminalCommand.startQueryResult(commandId);//命令下发成功,根据命令id,开始尝试获取检索结果
            }else {
                $("#vasCommandMsg").html("提交失败! 错误原因：" + (result.message ? result.message : result.Data));
                //停止所有的在$('body')上定时器
                $('#vasBody').stopTime (timerName);
            }
		});
    });

	 Utility.ajaxSubmitForm("vasEntityForm", {
						 success:function(responseText)
						 {
							   var result = responseText;
								if (result.success) {
									 var commandId = result.data; //下发成功后，获取到命令Id
									 tc2VideoalarmShield.startQueryResult(commandId);//命令下发成功,根据命令id,开始尝试获取检索结果
								}
								else {
									$("#vasCommandMsg").html("提交失败! 错误原因：" + (result.message ? result.message : result.Data));
									//停止所有的在$('body')上定时器  
									$('#vasBody').stopTime (timerName);  
								  }
						 }
	 });
});
</script>
 <BODY id="vasBody">
	<form id="vasEntityForm" name="vasEntityForm" 
			action='<%=ApplicationPath%>/videoTerminalParam/configVideoAlarmShield.action' method="POST">
				<!--超速设置-->
        <input type="hidden"  name="operation"  id="operation" value="modify"/>
        <input type="hidden"  name="vehicleId"  id="vehicleId" value="${vehicleId}"/>
  <table width="100%"  class="TableBlock">
					<tbody><tr>
						<td colspan="2" style="font-weight: bold; background: #EFEFEF;" height="25">终端视频报警屏蔽设置
						<span style="color:red;background:blue;">${message}</span>
						</td>
					</tr>

					<tr>
						<td align="right" rowspan="2">报警屏蔽:</td>
						<td >

							<input id="alarmType0" type="checkbox" name="alarmType" value="0" />视频信号丢失报警
							<input id="alarmType1" type="checkbox" name="alarmType" value="1" />视频信号遮挡报警
							<br/>
							<input id="alarmType2" type="checkbox" name="alarmType" value="2" />存储单元故障报警
							<input id="alarmType3" type="checkbox" name="alarmType" value="3" />其他视频设备故障报警
							<br/>
							<input id="alarmType4" type="checkbox" name="alarmType" value="4" />客车    超员    报警
							<input id="alarmType5" type="checkbox" name="alarmType" value="5" />异常驾驶行为报警
							<br/>
							<input id="alarmType6" type="checkbox" name="alarmType" value="6" />特殊报警录像达到存储阈值报警
						</td>
					</tr>

					<tr>

						<td colspan=2 align="center">

							<button id="vasBtnConfig" type="submit" class="button green medium sendjson" ><i class="fa fa-cog" style="margin-right:3px;"></i> 设置参数</button>

							<button id="vasBtnQuery" type="button" class="button blue medium " ><i class="fa fa-reply-all" style="margin-right:3px;"></i> 查询参数</button>

							<span id="vasCommandMsg" class="commandMsg"></span></td>
						
					</tr>

				
					
				</tbody></table>
				</form>
 </BODY>
</HTML>
